<template>
    <div id="myStudentList">
         <table class="table table-bordered">
             <tbody>
                <tr class="tableHeader">
                    <td>姓名</td>
                    <td>联系电话</td>
                    <td>上门时间</td>
                    <td>咨询师</td>
                    <td>状态</td>
                    <td>判量</td>
                    <td>试学</td>
                    <td>报名</td>
                    <td>操作</td>
                </tr>
                <tr v-for="(item,key) in dataSource" :key="key" class="tableRow">
                    <td>{{item.sname}}</td>
                    <td>{{item.mobile}}</td>
                    <td>{{item.arriveTime}}</td>
                    <td>{{item.advisor}}</td>
                    <td v-status="item.status">{{item.status|showStatus()}}</td>
                    <td>{{item.grade|filterGrade}}</td>
                    <td>{{item.isTry?"是":"否"}}</td>
                    <td>{{item.isPay?"是":"否"}}</td>
                    <td>
                         <el-button
                        size="mini"
                        @click="follow(key, item)"  type="danger" plain>
                        跟踪</el-button>
                    </td>
                </tr>
             </tbody>
         </table>
    </div>
</template>

<script>
    export default {
        data(){
            return {
                dataSource: []
            }
        },
        methods: {
            follow(index,visitor){
                localStorage.setItem("currentVisitor",JSON.stringify(visitor));
                this.$router.push({name:'FollowVisitor',params: {currentVisitor: visitor}})
            },
        },
        created(){
            var currentUser = JSON.parse(localStorage.getItem('responseData')).account.accountName;
            this.$http.get(window.baseURL + '/backstage/social/findByPage?token='+this.$token+'&advisor='+currentUser)
            .then((response)=>{
                this.dataSource = response.data.data.list.results;
            })
        },
        filters: {
            showStatus(value,isHopeful){
                var status = ["2天之内关单","1周内关单","长期跟单","无效量",'休学','退学','失联'];
                // var colors = ['lightgreen','LightGoldenrodYellow','Turquoise','WhiteSmoke'];
                // statusStyle.backgroundColor = colors[value-1];
                return status[value-1];
            },
            filterGrade(value){
                var arr = ['A','B','C','D'];
                return arr[value];
            }
        },
    }
</script>

<style lang="scss" scoped>
    #myStudentList {
        padding: 50px;
    }
</style>
